// 定义日期格式化函数

export function formatDate(date) {
  const today = new Date();
  const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];

  const year = date.getFullYear();
  const month = (date.getMonth() + 1).toString().padStart(2, '0');
  const day = date.getDate().toString().padStart(2, '0');
  const weekDay = date.getDay();

  // 判断是否是今天、明天、后天
  let time = year + "-" + month + "-" + day;
  if (date.toDateString() === today.toDateString()) {
    return {time: time, day: '今天', date: `${month}-${day}`, year: `${year}`};
  } else if (date.toDateString() === new Date(today.getTime() + 24 * 60 * 60 * 1000).toDateString()) {
    return {time: time, day: '明天', date: `${month}-${day}`, year: `${year}`};
  } else if (date.toDateString() === new Date(today.getTime() + 2 * 24 * 60 * 60 * 1000).toDateString()) {
    return {time: time, day: '后天', date: `${month}-${day}`, year: `${year}`};
  } else {
    // 格式化日期并显示周几
    return {time: time, day: weekDays[weekDay], date: `${month}-${day}`, year: `${year}`};
  }
}

